<template>
	<LayoutList>


		<template v-if="Object.keys(demandData).length">
			<Tips :leftText="'创建时间:'+demandData.createTime" :rightText="TipsRightText" color="#98A5B3"> </Tips>
		</template>
		<!-- 投票界面 -->
		<Vote v-if="vote.length" :data="vote" :itemCode="itemCode"></Vote>

		<template v-if="Object.keys(demandData).length">

			<Card>
				<template #head>
					需求信息
				</template>
				<template #body>
					<ItemDetail label="需求标题" :value="demandData.title"></ItemDetail>
					<ItemDetail label="需求描述" :value="demandData.remark"></ItemDetail>
					<view class="u-flex ">
						<view class="u-flex-1">
							<template v-if="demandData.itemType != null">
								<ItemDetail label="需求类型" :value="demandData.itemType | itemType"></ItemDetail>
							</template>

						</view>
						<view class="u-flex-1">
							<template v-if="demandData.level != null">

								<ItemDetail label="项目优先级" :value="demandData.level  | itemLevel"></ItemDetail>
							</template>
						</view>

					</view>
					<template v-if="demandData.proposerList && demandData.proposerList.length">

						<view v-for=" (item,index) in  demandData.proposerList " :key="index">
							<ItemDetail :label="`提出科室${index+1}`" :value="item.organizer | subject"></ItemDetail>
							<view class="u-flex">
								<view class="u-flex-1">
									<ItemDetail :label="`提出人${index+1}`" :value="item.sponsor"></ItemDetail>
								</view>
								<view class="u-flex-1">
									<ItemDetail :label="`联系电话${index+1}`" :value="item.phone"></ItemDetail>
								</view>
							</view>
						</view>
					</template>
					<view class="u-flex">
						<view class="u-flex-1">
							<template v-if="demandData.startTime != null">

								<ItemDetail label="提出日期" :value="demandData.startTime | date"></ItemDetail>
							</template>

						</view>
						<view class="u-flex-1">
							<template v-if="demandData.endTime != null">
								<ItemDetail label="期望日期" :value="demandData.endTime | date"></ItemDetail>
							</template>
						</view>
					</view>
					<template v-if="demandData.aboutSystem !=null">
						<ItemDetail label="涉及系统" :value="demandData.aboutSystem | aboutSystem"></ItemDetail>
					</template>
					<ItemDetail label="附件" :value="demandData.enclosure" type="attachment"></ItemDetail>
				</template>
			</Card>
		</template>
		<template v-if=" Object.keys(investigateData).length">
			<Card>
				<template #head>
					调研信息
				</template>
				<template #body>
					<ItemDetail label="调研负责人" :value="investigateData.principal | user"></ItemDetail>
					<ItemDetail label="调研成员" :value="investigateData.users | users"></ItemDetail>
					<ItemDetail label="操作时间" :value="investigateData.createTime"></ItemDetail>
					<ItemDetail label="调研地点" :value="investigateData.place"></ItemDetail>

					<ItemDetail label="调研时间" :value="investigateData.startTime"></ItemDetail>
					<ItemDetail label="期望日期" :value="investigateData.endTime | date "></ItemDetail>
					<template v-if="investigateData.aboutSystem !=null">

						<ItemDetail label="涉及系统" :value="investigateData.aboutSystem  | aboutSystem"></ItemDetail>
					</template>
					<ItemDetail label="需求目的" :value="investigateData.purpose"></ItemDetail>
					<view class="textColor">
						<view class="f28 bold  textColor" style="padding: 20rpx;">调研内容</view>
						<view class="contains between-flex">
							<view class="text">
								<view><span class="c999" style="width:100%;">业务描述：</span></view>
								<view class="f28 textColor">
									{{investigateData.outline || '无'}}
								</view>
								<view><span class="c999" style="width:100%;">解决方案设计:</span></view>
								<view class="f28 textColor">
									{{investigateData.functions || '无'}}
								</view>
								<view><span class="c999" style="width:100%;">后续行动计划:</span></view>
								<view class="f28 textColor">
									{{investigateData.followUpActionPlan || '无'}}
								</view>
								<view>
									<view><span class="c999" style="width:100%;">其他要求:</span></view>
									<view class="f28 textColor">
										{{investigateData.other?investigateData.other:'无'}}
									</view>
								</view>

							</view>

						</view>
						<ItemDetail label="附件:" :value="investigateData.enclosure" type="attachment"></ItemDetail>
					</view>
				</template>
			</Card>
		</template>


		<!-- 初定级信息 -->
		<template v-if="Object.keys(preliminaryLevelData).length ">
			<Card>
				<template #head>
					初定级信息
				</template>
				<template #body>
					<ItemDetail label="项目级别" v-if="preliminaryLevelData.projectLevel != null" :value="preliminaryLevelData.projectLevel | itemProjectLevel"></ItemDetail>
					<ItemDetail label="项目优先级" v-if="preliminaryLevelData.priority != null" :value="preliminaryLevelData.priority | itemPriority"></ItemDetail>
					<ItemDetail label="项目类型" v-if="preliminaryLevelData.projectType != null" :value="preliminaryLevelData.projectType | projectType"></ItemDetail>
					<ItemDetail label="项目负责人" :value="preliminaryLevelData.principal| user"></ItemDetail>
					<ItemDetail label="业务答辩人" :value="preliminaryLevelData.businessRespondent| users"></ItemDetail>
					<ItemDetail label="技术答辩人" :value="preliminaryLevelData.technicalRespondent| users"></ItemDetail>
					<ItemDetail label="其他参与人" :value="preliminaryLevelData.otherRespondent| users"></ItemDetail>
				</template>
			</Card>
		</template>
		<!-- 需求分析信息 -->
		<template v-if="Object.keys(demandAnalysisData).length ">
			<Card>
				<template #head>
					需求分析信息
				</template>
				<template #body>
					<view class="u-flex">
						<view class="u-flex-1">
							<CellDetail label="需求分析人" :value="demandAnalysisData.analyst | user "></CellDetail>
						</view>
						<view class="u-flex-1">
							<CellDetail label="需求类型" v-if="demandAnalysisData.type != null" :value="demandAnalysisData.type | itemType"></CellDetail>
						</view>
					</view>
					<CellDetail label="核心需求" :value="demandAnalysisData.coreDemand"></CellDetail>
					<CellDetail label="需求价值" :value="demandAnalysisData.demandValue"></CellDetail>
					<CellDetail label="技术分析人" :value="demandAnalysisData.analystTechnical  | user"></CellDetail>
					<CellDetail label="涉及业务领域" v-if="demandAnalysisData.domain != null" :value="demandAnalysisData.domain | coverageInvolved"></CellDetail>
					<CellDetail label="涉及系统" v-if="demandAnalysisData.aboutSystem != null" :value="demandAnalysisData.aboutSystem | aboutSystem"></CellDetail>
					<CellDetail label="分析备注" :value="demandAnalysisData.remark"></CellDetail>
					<CellDetail label="附件" :value="demandAnalysisData.enclosure" type="attachment"></CellDetail>
				</template>
			</Card>

		</template>

		<!-- 技术分析信息 -->
		<template v-if="Object.keys(technicalAnalysisData).length ">
			<Card>
				<template #head>
					技术分析信息
				</template>
				<template #body>

					<CellDetail label="难易程度" v-if="technicalAnalysisData.difficulty != null" :value="technicalAnalysisData.difficulty | difficulty"></CellDetail>
					<CellDetail label="当前技术风险" :value="technicalAnalysisData.technicalRisk"></CellDetail>
					<CellDetail label="建议解决方案" :value="technicalAnalysisData.solution  "></CellDetail>
					<CellDetail label="实施形式" v-if="technicalAnalysisData.applyType != null" :value="technicalAnalysisData.applyType  | implementation_form"></CellDetail>
					<CellDetail label="评估备注" :value="technicalAnalysisData.remark"></CellDetail>
					<CellDetail label="附件" :value="technicalAnalysisData.enclosure" type="attachment"></CellDetail>
				</template>
			</Card>
		</template>
		<!-- 需求评估信息 -->
		<template v-if="Object.keys(demandAssessData).length">
			<Card>
				<template #head>
					需求评估信息
				</template>
				<template #body>

					<!-- 评估通过 -->
					<template v-if="demandAssessData.result == 1">
						<view class="contains">
							<CellDetail label="评估结果" value="通过"></CellDetail>
							<CellDetail label="项目优先级" v-if="demandAssessData.priority !=null" :value="demandAssessData.priority | itemPriority"></CellDetail>
							<CellDetail label="项目级别" v-if="demandAssessData.projectLevel !=null" :value="demandAssessData.projectLevel | itemProjectLevel  "></CellDetail>
							<CellDetail label="项目负责人" :value="demandAssessData.principal  | user"></CellDetail>
							<CellDetail label="项目类型" v-if="demandAssessData.projectType !=null" :value="demandAssessData.projectType | projectType"></CellDetail>
							<CellDetail label="业务答辩人" :value="demandAssessData.businessRespondent | user"></CellDetail>
							<CellDetail label="技术答辩人" :value="demandAssessData.technicalRespondent | user"></CellDetail>
							<CellDetail label="其他参与人" :value="demandAssessData.otherRespondent |users"></CellDetail>
						</view>
					</template>
					<!-- 不通过 -->
					<template v-if="demandAssessData.result == 2">
						<CellDetail label="评估结果" value="不通过"></CellDetail>
						<CellDetail label="不通过理由" :value="demandAssessData.failReason"></CellDetail>
					</template>
					<!-- 继续调研 -->
					<template v-if="demandAssessData.result == 3">
						<CellDetail label="评估结果" value="继续调研理由"></CellDetail>
						<CellDetail label="不通过理由" :value="demandAssessData.continueReason"></CellDetail>
					</template>
					<!-- 转工单 -->
					<template v-if="demandAssessData.result == 4">
						<CellDetail label="评估结果" value="转工单"></CellDetail>
						<CellDetail label="报修人" :value="demandAssessData.use | userr"></CellDetail>
						<CellDetail label="报修人电话" :value="demandAssessData.phone"></CellDetail>
						<CellDetail label="报修科室" :value="demandAssessData.deptId | subject"></CellDetail>
						<CellDetail label="故障分类" v-if="demandAssessData.faultType != null" :value="demandAssessData.faultType | faultClassification"></CellDetail>
						<CellDetail label="故障描述" :value="demandAssessData.faultRemark"></CellDetail>
						<CellDetail label="预计工时(小时)" :value="demandAssessData.reqTime "></CellDetail>
						<CellDetail label="指派人员" :value="demandAssessData.sendUser |user "></CellDetail>
						<CellDetail label="紧急程度" v-if="demandAssessData.degree != null" :value="demandAssessData.degree | gradeUrgency"></CellDetail>
						<CellDetail label="影响范围" v-if="demandAssessData.rangeType != null" :value="demandAssessData.rangeType | faultScope"></CellDetail>
						<CellDetail label="报修时间" :value="demandAssessData.createTime | date"></CellDetail>
					</template>
				</template>
			</Card>

		</template>
		<template #footer>

			<OptionMenu :data="OptionMenuData" :state="state" :dataPackage="demandData"></OptionMenu>
		</template>


	</LayoutList>
</template>

<script>
	import PagesCourseRouterConfig from '@/pagesCourse/routerConfig.js'
	import PagesProjectRouterConfig from '@/pagesProject/routerConfig.js'
	import PagesDemandRouterConfig from '@/pagesDemand/routerConfig.js'
	import ProjectApi from '@/apis/project.js'
	import ButtonBewtten from '@/components/buttonGroup/optionButtonGroup.vue'
	import CellDetail from '@/components/cell/itemDetail.vue'
	import Vote from '@/pages/demand/components/card/detail/vote.vue'
	import HButton from '@/components/button/index.vue'
	import OptionMenu from './operation/optionMenu.vue'
	import LayoutList from '@/components/layout/listLayout.vue'
	import Card from '@/components/card/components/cardDetail.vue'
	import Tips from '@/components/tips/orderTips.vue'
	import ItemDetail from '@/components/cell/itemDetail.vue'
	export default {
		filters: {

			testFilter() {
				return 'testFilter'
			}
		},
		components: {
			CellDetail,
			Tips,
			ButtonBewtten,
			Vote,
			HButton,
			OptionMenu,
			LayoutList,
			Card,
			ItemDetail
		},
		computed: {

			TipsRightText() {
				if (this.demandData?.createUser) {
					let name = this.$options.filters.user(this.demandData.createUser)
					console.log(name, '-----');
					return `创建人:${name}`
				}
				return ''
			},

			OptionMenuData() {
				let { createUser } = this.demandData || {}
				let { investigate, users } = this.investigateData || {}
				let { analystTechnical } = this.demandAnalysisData || {}
				return {
					createUser,
					investigate: investigate || '',
					users: users || '',
					analystTechnical: analystTechnical || '',
					itemCode: this.itemCode
				}
			},
		},
		data() {
			return {
				PagesCourseRouterConfig,
				PagesProjectRouterConfig,
				PagesDemandRouterConfig,
				packageData: {},
				state: '',
				itemCode: 0,
				vote: [], //投票信息,

				demandData: {},
				// 调研数据
				investigateData: {},
				// 初定级数据
				preliminaryLevelData: {},
				// 需求分析信息 数据
				demandAnalysisData: {},
				// 技术评估信息数据
				technicalAnalysisData: {},
				// 需求评估信息数据
				demandAssessData: {},
				// 需求评审信息数据
				demandReviewData: {},



			}
		},
		onLoad(e) {
			this.state = e.state
			this.itemCode = e.itemCode
			this.init()

		},

		onShow() {
			this.getVote()

		},
		methods: {
			init() {
				ProjectApi.Demand.GetDemandDetail(this.itemCode).then(res => {
					if (res.code == 0) {
						let { demand, investigate, firstGrading, demandAnalysis, technicalAnalysis, demandAssess, demandReview } = res.body
						this.demandData = demand || {}
						this.investigateData = investigate || {}
						this.preliminaryLevelData = firstGrading || {}
						this.demandAnalysisData = demandAnalysis || {}
						this.technicalAnalysisData = technicalAnalysis || {}
						this.demandAssessData = demandAssess || {}
						this.demandReviewData = demandReview || {}
					}
				})

			},
			getVote() {
				this.$pop.ajaxPost('/busItemDemand/getReviewDetail', {
					itemCode: this.itemCode
				}).then(res => {
					if (res.code == 0) {
						this.vote = res.body.vote
					}
				})
			}

		}
	}
</script>
